import { EntityModel } from '@midwayjs/orm';
import { BaseEntity } from 'midwayjs-cool-core';
import { Column, PrimaryGeneratedColumn } from 'typeorm';

@EntityModel('customer_address')
export class CustomerAddressEntity extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: '收货人' })
  name: string;

  @Column({
    comment: '性别',
    type: 'enum',
    enum: ['man', 'woman', 'unknown'],
    default: 'unknown',
  })
  sex: string;

  @Column({ comment: '电话' })
  phone: string;

  @Column({ comment: '省' })
  province: string;

  @Column({ comment: '市' })
  city: string;

  @Column({ comment: '区' })
  area: string;

  @Column({ comment: '街道' })
  street: string;

  @Column({ comment: '详细地址' })
  detail: string;

  @Column({ comment: '默认地址', default: false })
  isDefault: boolean;

  // 外键：映射到 customer
  @Column({ comment: 'ManyToOne: address => customer' })
  customerId: number;
}
